import {observable , action} from 'mobx';
import reqwest from 'reqwest';
import config from '../store/config.js';

export default class CouponModal {
  @observable data = {
    c_amount: 5000,
    c_getTimeType: 1,
    c_id: 1,
    c_name: "coupon1",
    c_remark: "",
    c_url: "https://www.taobao.com"
  };

  constructor(data, parent) {
    this.data = data;
    this.parent = parent;
  }

  @action updateCou(data) {
    console.log('data', data);
    reqwest({
      url: config.serverUrl +'coupon.do/updateCoupon',
      method: 'post',
      data: { ...data }
    }).then((data) => {
      console.log('data: ', data);
      this.parent.init();
      //if(data.succ) {
      //  this.setNewPalace(data)
      //} else {
      //  console.log(data)
      //}
    });
  }

}
